this.viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
this.dash.showAppsButton);
- this.viewSelector.connect('page-empty', this._onPageEmpty.bind(this));
+ this.viewSelector.connect('notify::search-active', this._onSearchChanged.bind(this));
this._thumbnailsBox =
new WorkspaceThumbnail.ThumbnailsBox(this._workspaceAdjustment);
}
_updateThumbnailsBox(animate = false) {
- const page = this.viewSelector.getActivePage();
- const searching = page === ViewSelector.ViewPage.SEARCH;
+ const { searchActive } = this.viewSelector;
const [opacity, scale, translationY] = this._getThumbnailsBoxParams();
- const thumbnailsBoxVisible = !searching && opacity !== 0;
+ const thumbnailsBoxVisible = !searchActive && opacity !== 0;
if (thumbnailsBoxVisible) {
this._thumbnailsBox.opacity = 0;
this._thumbnailsBox.visible = thumbnailsBoxVisible;
}
const params = {
- opacity: searching ? 0 : opacity,
+ opacity: searchActive ? 0 : opacity,
duration: animate ? SIDE_CONTROLS_ANIMATION_TIME : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => (this._thumbnailsBox.visible = thumbnailsBoxVisible),
};
- if (!searching) {
+ if (!searchActive) {
params.scale_x = scale;
params.scale_y = scale;
params.translation_y = translationY;
this._updateThumbnailsBox();
}
- _onPageEmpty() {
- const page = this.viewSelector.getActivePage();
- const isActivities = page === ViewSelector.ViewPage.ACTIVITIES;
+ _onSearchChanged() {
+ const { searchActive } = this.viewSelector;
- if (isActivities) {
+ if (!searchActive) {
this._appDisplay.show();
this._workspacesDisplay.reactive = true;
this._workspacesDisplay.setPrimaryWorkspaceVisible(true);
this._updateThumbnailsBox(true);
this._appDisplay.ease({
- opacity: isActivities ? 255 : 0,
+ opacity: searchActive ? 0 : 255,
duration: SIDE_CONTROLS_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
- onComplete: () => (this._appDisplay.visible = isActivities),
+ onComplete: () => (this._appDisplay.visible = !searchActive),
});
this._workspacesDisplay.ease({
- opacity: isActivities ? 255 : 0,
+ opacity: searchActive ? 0 : 255,
duration: SIDE_CONTROLS_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
- this._workspacesDisplay.reactive = isActivities;
- this._workspacesDisplay.setPrimaryWorkspaceVisible(isActivities);
+ this._workspacesDisplay.reactive = !searchActive;
+ this._workspacesDisplay.setPrimaryWorkspaceVisible(!searchActive);
},
});
this.viewSelector.ease({
- opacity: isActivities ? 0 : 255,
+ opacity: searchActive ? 255 : 0,
duration: SIDE_CONTROLS_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
- onComplete: () => (this.viewSelector.visible = !isActivities),
+ onComplete: () => (this.viewSelector.visible = searchActive),
});
}
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported ViewSelector */
-const { Clutter, GObject, Shell, St } = imports.gi;
+const { Clutter, GObject, St } = imports.gi;
const Main = imports.ui.main;
-const OverviewControls = imports.ui.overviewControls;
const Search = imports.ui.search;
const ShellEntry = imports.ui.shellEntry;
-var ViewPage = {
- ACTIVITIES: 1,
- SEARCH: 2,
-};
-
var FocusTrap = GObject.registerClass(
class FocusTrap extends St.Widget {
vfunc_navigate_focus(from, direction) {
}
var ViewSelector = GObject.registerClass({
- Signals: {
- 'page-changed': {},
- 'page-empty': {},
+ Properties: {
+ 'search-active': GObject.ParamSpec.boolean(
+ 'search-active', 'search-active', 'search-active',
+ GObject.ParamFlags.READABLE,
+ false),
},
-}, class ViewSelector extends Shell.Stack {
+}, class ViewSelector extends St.Widget {
_init(searchEntry, showAppsButton) {
super._init({
name: 'viewSelector',
+ layout_manager: new Clutter.BinLayout(),
x_expand: true,
y_expand: true,
visible: false,
this._iconClickedId = 0;
this._capturedEventId = 0;
- const dummy = new St.Widget();
- this._activitiesPage =
- this._addPage(dummy, _('Activities'), 'view-app-grid-symbolic');
-
this._searchResults = new Search.SearchResultsView();
- this._searchPage = this._addPage(this._searchResults);
+ this.add_child(this._searchResults);
Main.ctrlAltTabManager.addGroup(this._entry, _('Search'), 'edit-find-symbolic');
// Since the entry isn't inside the results container we install this
prepareToEnterOverview() {
this.reset();
- this._activePage = null;
- this._showPage(this._activitiesPage);
+ this._setSearchActive(false);
}
vfunc_unmap() {
super.vfunc_unmap();
}
- _addPage(actor) {
- let page = new St.Bin({ child: actor });
- page.hide();
- this.add_actor(page);
- return page;
- }
-
- _fadePageIn() {
- this._activePage.ease({
- opacity: 255,
- duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
- mode: Clutter.AnimationMode.EASE_OUT_QUAD,
- });
- }
-
- _fadePageOut(page) {
- let oldPage = page;
- page.ease({
- opacity: 0,
- duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
- mode: Clutter.AnimationMode.EASE_OUT_QUAD,
- onStopped: () => this._animateIn(oldPage),
- });
- }
-
- _animateIn(oldPage) {
- if (oldPage)
- oldPage.hide();
-
- this.emit('page-empty');
-
- if (this._activePage) {
- this._activePage.show();
- this._fadePageIn();
- }
- }
-
- _animateOut(page) {
- this._fadePageOut(page);
- }
-
- _showPage(page) {
- if (!Main.overview.visible)
+ _setSearchActive(searchActive) {
+ if (this._searchActive === searchActive)
return;
- if (page == this._activePage)
- return;
-
- let oldPage = this._activePage;
- this._activePage = page;
- this.emit('page-changed');
-
- if (oldPage)
- this._animateOut(oldPage);
- else
- this._animateIn();
+ this._searchActive = searchActive;
+ this.notify('search-active');
}
_onShowAppsButtonToggled() {
- this._showPage(this._activitiesPage);
+ this._setSearchActive(false);
}
_onStageKeyPress(actor, event) {
}
_searchCancelled() {
- this._showPage(this._activitiesPage);
+ this._setSearchActive(false);
// Leave the entry focused when it doesn't have any text;
// when replacing a selected search term, Clutter emits
_onTextChanged() {
let terms = getTermsForSearchString(this._entry.get_text());
- this._searchActive = terms.length > 0;
+ const searchActive = terms.length > 0;
this._searchResults.setTerms(terms);
- if (this._searchActive) {
- this._showPage(this._searchPage);
+ if (searchActive) {
+ this._setSearchActive(true);
this._entry.set_secondary_icon(this._clearIcon);
return Clutter.EVENT_PROPAGATE;
}
- getActivePage() {
- if (this._activePage === this._activitiesPage)
- return ViewPage.ACTIVITIES;
- else
- return ViewPage.SEARCH;
+ get searchActive() {
+ return this._searchActive;
}
});